﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using RB.Web.Security.Rdb;

namespace RB.Web.Security.Wcf
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码和配置文件中的类名“Service1”。
    public class MembershipService : IMembershipService
    {
        public bool CreateUser(UserAccount userAccount)
        {
            DbMembershipService service = new DbMembershipService();
            return service.CreateUser(userAccount);
        }

        public bool DeleteUser(string username, bool deleteAllRelatedData, string deleteBy)
        {
            DbMembershipService service = new DbMembershipService();
            return service.DeleteUser(username, deleteAllRelatedData, deleteBy);
        }

        public IList<UserAccount> FindUsersByEmail(string emailToMatch)
        {
            DbMembershipService service = new DbMembershipService();
            return service.FindUsersByEmail(emailToMatch);
        }

        public IList<UserAccount> FindUsersByName(string usernameToMatch)
        {
            DbMembershipService service = new DbMembershipService();
            return service.FindUsersByName(usernameToMatch);
        }

        public IList<UserAccount> GetAllUsers()
        {
            DbMembershipService service = new DbMembershipService();
            return service.GetAllUsers();
        }

        public int GetNumberOfUsersOnline(int userIsOnlineTimeWindow)
        {
            DbMembershipService service = new DbMembershipService();
            return service.GetNumberOfUsersOnline(userIsOnlineTimeWindow);
        }

        public UserAccount GetUserByName(string username, bool userIsOnline)
        {
            DbMembershipService service = new DbMembershipService();
            return service.GetUserByName(username, userIsOnline);
        }

        public UserAccount GetUserByKey(Guid providerUserKey, bool userIsOnline)
        {
            DbMembershipService service = new DbMembershipService();
            return service.GetUserByKey(providerUserKey, userIsOnline);
        }

        public UserAccount GetUserByEmail(string email)
        {
            DbMembershipService service = new DbMembershipService();
            return service.GetUserByEmail(email);
        }

        public bool UnlockUser(string userName)
        {
            DbMembershipService service = new DbMembershipService();
            return service.UnlockUser(userName);
        }

        public void UpdateUser(UserAccount user)
        {
            DbMembershipService service = new DbMembershipService();
            service.UpdateUser(user);
        }

        public bool LoginUser(string username, string password, int maxInvalidPasswordAttempts, int passwordAttemptWindow)
        {
            DbMembershipService service = new DbMembershipService();
            return service.LoginUser(username, password, maxInvalidPasswordAttempts, passwordAttemptWindow);
        }

        public bool ValidateUser(string username, string password)
        {
            DbMembershipService service = new DbMembershipService();
            return service.ValidateUser(username, password);
        }

        public bool ChangePassword(string username, string newPassword, string changeBy)
        {
            DbMembershipService service = new DbMembershipService();
            return service.ChangePassword(username, newPassword, changeBy);
        }

        public bool ChangePasswordQuestionAndAnswer(string username, string newPasswordQuestion, string newPasswordAnswer, string changeBy)
        {
            DbMembershipService service = new DbMembershipService();
            return service.ChangePasswordQuestionAndAnswer(username, newPasswordQuestion, newPasswordAnswer, changeBy);
        }

        public string GetPassword(string username)
        {
            DbMembershipService service = new DbMembershipService();
            return service.GetPassword(username);
        }

        public bool ValidatePasswordAnswer(string username, string answer)
        {
            DbMembershipService service = new DbMembershipService();
            return service.ValidatePasswordAnswer(username, answer);
        }

        public void AddUserToApp(Guid userId, string appCode, string createBy)
        {
            DbMembershipService service = new DbMembershipService();
            service.AddUserToApp(userId, appCode, createBy);
        }
    }
}
